package cn.kgc.service.impl;

import cn.kgc.dao.InterViewDao_yy;
import cn.kgc.dao.ResumeDao_yy;
import cn.kgc.pojo.Resume_yy;
import cn.kgc.service.ResumeService_yy;
import cn.kgc.util.UploadUtil;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: yy
 * @date: 2022/2/17
 * @description:
 */
@Service
public class ResumeServiceImpl_yy implements ResumeService_yy {
    @Resource
    private ResumeDao_yy rd;

    @Resource
    private InterViewDao_yy id;


    @Resource
    private UploadUtil uploadUtil;
    @Override
    public boolean addRyy(MultipartFile multipartFile,Resume_yy resume, String status) {

//        if(!resume.getInterView().equals("是")){
//            status ="存档";
//            resume.setReferrer("");
//            resume.setTime(null);
//            resume.setComment("");
//        }else {
//            status ="推荐面试";
//        }
        
        String oldFilename = multipartFile.getOriginalFilename();//上传文件名
        //String newFileName = UUID.randomUUID().toString() + suffix;//文件新名字
        String servrepath = System.getProperty("user.dir")+"\\src\\main\\resources\\upload\\";//路径

        resume.setFilePath(servrepath);
        resume.setFileName(oldFilename);



        int a = rd.addRyy(resume);
        int b = id.sddIyy(resume.getResumeId(), status);
        if (a > 0 && b > 0) {
            uploadUtil.uploadImg(multipartFile);
            return true;
        }
        return false;
    }

    @Override
    public List<Resume_yy> selRyy(String name, String positionName, String experience, String status, String rTimes) {
        return rd.selRyy(name, positionName, experience, status,rTimes);
    }

    @Override
    public Resume_yy chaRyy(int resumeId) {
        return rd.chaRyy(resumeId);
    }


    @Override
    public boolean xiuRyy(MultipartFile multipartFile,Resume_yy resume) {

        String oldFilename = multipartFile.getOriginalFilename();//上传文件名
        //String newFileName = UUID.randomUUID().toString() + suffix;//文件新名字
        String servrepath = System.getProperty("user.dir")+"\\src\\main\\resources\\upload\\";//路径

        resume.setFilePath(servrepath);
        resume.setFileName(oldFilename);

        if(rd.xiuRyy(resume)>0){
            uploadUtil.uploadImg(multipartFile);
            return true;
        }
        return false;
    }


}
